<%--
  Created by IntelliJ IDEA.
  User: azure
  Date: 2021/10/26
  Time: 16:32
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>书籍所有信息</title>
    <style>
        body {
            background-color: #ccc;
        }

        a {
            text-decoration: none;
            color: brown;
        }

        * {
            margin: 0;
            padding: 0;
        }

        .title {
            height: 40px;
            width: 200px;
            margin: 50px auto;
            font-size: 30px;
        }

        table {
            width: 600px;
            height: 350px;
            border: 1px solid #747474;
            margin: auto;
        }

        table,
        td {
            cursor: pointer;
            border-collapse: collapse;
            text-align: center;
            background-color: #F8DB79;
        }

        /* tr下的第一个元素： */

        tr:nth-child(1) {
            font-weight: 700;
        }

        th,
        td {
            border: 1px solid #747474;
        }

        .addBook a {
            display: block;
            width: 100px;
            height: 20px;
            text-decoration: none;
            color: cadetblue;
            border: 1px solid cadetblue;
            text-align: center;
            line-height: 20px;
            margin: 20px auto;
        }

        .addBook a:hover {
            background-color: #747474;
            color: cornflowerblue;
        }
    </style>

    <script>
        function deleteBook(id) {
            /*
                安全提示：
             */
            var flag = confirm('您确定要删除吗?');
            if (flag) {
                //点击确认后,将地址转给 delUserServlet：
                location.href = "${pageContext.request.contextPath}/books/deleteBook?bid=" + id;
            }
        }
    </script>
</head>
<body>
<h3 class="title">书籍管理系统</h3>
<div class="addBook">
    <a href="${pageContext.request.contextPath}/books/btnInBook">添加书籍</a>
</div>
<table>
    <tr>
        <td>ID</td>
        <td>书名</td>
        <td>数量</td>
        <td>描述</td>
        <td>操作</td>
    </tr>
    <jsp:useBean id="books" scope="request" type="java.util.List"/>
    <c:forEach items="${books}" var="book">
        <tr>
            <td>${book.bookId}</td>
            <td>${book.bookName}</td>
            <td>${book.bookCounts}</td>
            <td>${book.detail}</td>
            <td>
                <a href="javascript:deleteBook(${book.bookId})">删除</a>
                <a href="${pageContext.request.contextPath}/books/btnUpdateBook?bookId=${book.bookId}">修改</a>
            </td>
        </tr>
    </c:forEach>

</table>
<div style="width: 200px;height: 100px;font-size: 13px;margin: 100px auto">技术支持：卫鹏</div>
</body>
</html>
